package cn.am.mapper;

import cn.am.pojo.PlanVO;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * @Author : ArturiaMu KMUST-Stu
 * @Date : 2022/8/14 12:30
 * @Params : @param null
 * @Exception :
 * @Return :
 * @Description ：
 */
@Mapper
public interface PlanMapper {
    @Insert("insert into plan(plan_time,user_id,user_avatar,user_name,`plan`) values(#{planTime},#{userId},#{userAvatar},#{userName},#{plan})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int save(PlanVO planVO);

    @Delete("delete from plan where id=#{id}")
    int del(Long id);

    @Select("select id,plan_time as planTime,user_id as userId,user_avatar as userAvatar,user_name as userName,`plan` from plan where plan_time > #{date}")
    List<PlanVO> getAvailablePlan(Date date);

    @Select("select id,plan_time as planTime,user_id as userId,user_avatar as userAvatar,user_name as userName,`plan` from plan where user_id = #{uid}")
    List<PlanVO> getByUserId(Long uid);

    @Select("select id,plan_time as planTime,user_id as userId,user_avatar as userAvatar,user_name as userName,`plan` from plan where id = #{id}")
    PlanVO getById(Long id);
}
